<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
	<th:block th:include="include :: header('用户账户信息')" />
    <style type="text/css">.user-info-head{position:relative;display:inline-block;}.user-info-head:hover:after{content:'\f030';position:absolute;left:0;right:0;top:0;bottom:0;color:#eee;background:rgba(0,0,0,0.5);font-family:FontAwesome;font-size:24px;font-style:normal;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;cursor:pointer;line-height:110px;border-radius:50%;}</style>
</head>

<body class="gray-bg" style="font: 14px Helvetica Neue, Helvetica, PingFang SC, 微软雅黑, Tahoma, Arial, sans-serif !important;">
    <section class="section-content">
    <div class="row">

        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>账本资料</h5>
                </div>
                <div class="ibox-content">
                    <div class="row">
                        <div class="col-sm-6 b-r">
                            <!--账户信息-->
                            <div class="tab-pane active" id="tenant_info" th:object="${platformTenant}">
                                <form class="form-horizontal m" id="form-tenant-edit">
                                    <!--隐藏ID-->
                                    <input name="tenantId" th:field="*{tenantId}" type="hidden">
                                    <h3 class="m-t-none m-b">基本信息</h3>
                                    <div class="form-group">
                                        <label class="col-sm-3 control-label">*租户名称：</label>
                                        <div class="col-sm-8">
                                            <input name="tenantName" th:field="*{tenantName}" class="form-control" type="text">
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-3 control-label">租户编号：</label>
                                        <div class="col-sm-8">
                                            <input name="tenantNo" th:field="*{tenantNo}" class="form-control" type="text">
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-3 control-label">租户logo：</label>
                                        <div class="col-sm-8">
                                            <input name="logoUrl" th:field="*{logoUrl}" class="form-control" type="text">
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-3 control-label">备注：</label>
                                        <div class="col-sm-8">
                                            <textarea name="remark" class="form-control">[[*{remark}]]</textarea>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <div class="col-sm-offset-3 col-sm-8">
                                            <button type="button" class="btn btn-sm btn-success" onclick="submitUserInfo()"><i class="fa fa-check"></i>更新账本信息</button>
                                        </div>
                                    </div>
                                </form>
                            </div>
                        </div>
                        <div class="col-sm-3">
                            <div class="text-center">
                                <p>账户头像</p>
                                <p class="user-info-head" onclick="avatar()"><img class="img-circle img-lg" src="/img/profile.jpg"></p>
                                <p><button type="button" class="btn btn-sm btn-file" onclick="avatar()"><i class="fa fa-address-card"></i>更换头像</button></p>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
	</section>
    
    <th:block th:include="include :: footer" />
    <script>
	    /*用户管理-头像*/
	    function avatar() {
	        var url = ctx + 'system/user/profile/avatar';
	        top.layer.open({
        		type: 2,
        		area: [$(window).width() + 'px', $(window).height() + 'px'],
        		fix: false,
        		//不固定
        		maxmin: true,
        		shade: 0.3,
        		title: "修改头像",
        		content: url,
        		btn: ['确定', '关闭'],
        	    // 弹层外区域关闭
        		shadeClose: true,
        		yes: function(index, layero) {
                    var iframeWin = layero.find('iframe')[0];
                    iframeWin.contentWindow.submitHandler(index, layero);
                },
        	    cancel: function(index) {
        	        return true;
        	    }
        	});
	    }

	    /*用户信息-修改*/
	    $("#form-tenant-edit").validate({
			onkeyup: false,
			rules:{
				userName:{
					required:true,
				},
				email:{
					required:true,
		            email:true,
		            remote: {
		                url: ctx + "system/user/checkEmailUnique",
		                type: "post",
		                dataType: "json",
		                data: {
		                	"userId": function() {
		                        return $("#userId").val();
		                    },
		        			"email": function() {
		                        return $.common.trim($("#email").val());
		                    }
		                },
		                dataFilter: function (data, type) {
		                	return $.validate.unique(data);
		                }
		            }
				},
				phonenumber:{
					required:true,
					isPhone:true,
		            remote: {
		                url: ctx + "system/user/checkPhoneUnique",
		                type: "post",
		                dataType: "json",
		                data: {
		                	"userId": function() {
		                		return $("#userId").val();
		                    },
		        			"phonenumber": function() {
		                        return $.common.trim($("#phonenumber").val());
		                    }
		                },
		                dataFilter: function (data, type) {
		                	return $.validate.unique(data);
		                }
		            }
				},
			},
			messages: {
				"userName": {
	                required: "请输入用户名称",
	            },
				"email": {
					required: "请输入邮箱",
		            remote: "Email已经存在"
		        },
				"phonenumber":{
					required: "请输入手机号码",
		        	remote: "手机号码已经存在"
				}
		    },
		    focusCleanup: true
		});
		
		function submitUserInfo() {
	        if ($.validate.form()) {
	        	$.operate.saveModal(ctx + "system/tenant/profile/update", $('#form-tenant-edit').serialize());
	        }
	    }
	</script>
</body>
</html>
